package com.spdb.oa.type;

import java.io.File;
import java.util.ArrayList;

import javax.xml.bind.JAXB;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import com.spdb.oa.type.WorkflowOpinion.DepartmentOpinion;
import com.spdb.oa.type.WorkflowOpinion.Opinion;

@XmlRootElement(name="ReturnContent")
public class ReturnContent {
	@XmlElement(name="WorkFlowOpinion")
	public WorkflowOpinion workflowOpinion;
	
	@Override
	public String toString() {
		return "ReturnContent [workflowOpinion=" + workflowOpinion + "]";
	}

	public static void main(String[] args) throws JAXBException {
		ReturnContent rc = new ReturnContent();
		rc.workflowOpinion = new WorkflowOpinion();
		rc.workflowOpinion.departmentOpinions = new ArrayList<WorkflowOpinion.DepartmentOpinion>();
		rc.workflowOpinion.instanceId ="111";
		rc.workflowOpinion.processId = "222";
		
		DepartmentOpinion e = new DepartmentOpinion();
		e.controlType = "fwefe";
		e.id = "sdfe3433";
		e.opinions = new ArrayList<WorkflowOpinion.Opinion>();
		
		WorkflowOpinion.Opinion op = new Opinion();
		op.dealDateTime = "2015";
		op.dealDateTime = "lij";
		op.stepName = "hhfashd";
		e.opinions.add(op);
		rc.workflowOpinion.departmentOpinions.add(e);
		
//		JAXB.marshal(rc, new File("D:\\Users\\lij70\\workspace\\MobileOA\\src\\GetWorkFlowOpinionJaxb.xml"));
//		System.out.println(rc);
		
		ReturnContent rr = JAXB.unmarshal(new File("D:\\Users\\lij70\\workspace\\MobileOA\\src\\GetWorkFlowOpinion.xml"), ReturnContent.class);
		System.out.println(rr);
		System.out.println("Done...");
		
		JAXBContext context = JAXBContext.newInstance(ReturnContent.class);
		Unmarshaller um = context.createUnmarshaller();
//		um.unmarshal(source)
	}
}
